package com.kaiwukj.android.ufamily;

import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils;
import com.kaiwukj.android.ufamily.app.MyApplication;
import com.kaiwukj.android.ufamily.mvp.http.callback.ApiCallBack;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.GMOrderDetailResult;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.ServiceGroupResult;
import com.kaiwukj.android.ufamily.mvp.model.ServiceModel;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;

@RunWith(AndroidJUnit4.class)
public class ServiceTest {

    private ServiceModel mModel;

    @Before
    public void init() {
        mModel = new ServiceModel(MyApplication.getInstance().getAppComponent().repositoryManager());
    }

    @Test
    public void testFetchService() {
        mModel.fetchServiceGroup()
                .subscribe(new ApiCallBack<List<ServiceGroupResult>>() {
                    @Override
                    public void onSuccess(@NonNull List<ServiceGroupResult> result) {
                        LogUtils.d("result------------------>" + GsonUtils.toJson(result));
                    }
                });
    }

    @Test
    public void testGetGMOrderDetail() {
        mModel.getGMOrderDetail(11)
                .subscribe(new ApiCallBack<GMOrderDetailResult>() {
                    @Override
                    public void onSuccess(@NonNull GMOrderDetailResult result) {
                        System.out.println("result------------------>" + GsonUtils.toJson(result));
                    }
                });
    }
}
